package com.zhongxiangspace.service.impl;

import com.zhongxiangspace.entity.County;
import com.zhongxiangspace.entity.QueryAnalyzer;
import com.zhongxiangspace.entity.VO.TradeAreaVO;
import com.zhongxiangspace.mapper.CountyMapper;
import com.zhongxiangspace.service.CountyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 区县
 */
@Service
public class CountyServiceImpl implements CountyService {

    @Autowired
    private CountyMapper countyMapper;

    /**
     * 插入
     * @param county
     * @return
     */
    @Override
    @Transactional
    public boolean insert(County county) {
        return this.countyMapper.insert(county);
    }

    /**
     *  根据keyword 获取data
     * @param queryAnalyzer 条件
     * @return
     */
    @Override
    public List<County> queryByKeyword(QueryAnalyzer queryAnalyzer) {
        return this.countyMapper.queryByKeyword(queryAnalyzer);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    @Transactional
    public boolean delete(Integer id) {
        return this.countyMapper.delete(id);
    }

    /**
     * 获取单条data
     * @param id
     * @return
     */
    @Override
    public County queryOne(Integer id) {
        return this.countyMapper.queryOne(id);
    }

    /**
     * 更新状态
     * @param county
     * @return
     */
    @Override
    @Transactional
    public boolean updataStatusCode(County county) {
        return this.countyMapper.updataStatusCode(county);
    }

    /**
     * 更新data
     * @param county
     * @return
     */
    @Override
    @Transactional
    public boolean updata(County county) {
        return this.countyMapper.updata(county);
    }

    /**
     * 设置商圈热门和非热门
     * @param county
     * @return
     */
    @Override
    @Transactional
    public boolean updataHotCode(County county) {
        return this.countyMapper.updataHotCode(county);
    }
    /**
     * 父类下面的所有一类
     * @param parent_id 父类id
     * @return
     */
    @Override
    public List<County> queryAllType(Integer parent_id) {
        return this.countyMapper.queryAllType(parent_id);
    }

    /**
     * 根据父类id data
     * @param queryAnalyzer 条件
     * @return
     */
    @Override
    public List<Map<String,Object>> queryTradeAreaByKeyword(QueryAnalyzer queryAnalyzer) {
        return this.countyMapper.queryTradeAreaByKeyword(queryAnalyzer);
    }

    /**
     * 获取商圈信息
     * @param tradeAreaQueryAnalyzer 条件
     * @return
     */
    @Override
    public List<TradeAreaVO> queryTradeAreaVO(QueryAnalyzer tradeAreaQueryAnalyzer) {
        return this.countyMapper.queryTradeAreaVO(tradeAreaQueryAnalyzer);
    }

    /**
     * 获取商圈下房源数量
     * @return
     */
    @Override
    public List<Map<String, Object>> queryCountyByhouseNum() {
        return this.countyMapper.queryCountyByhouseNum();
    }
}
